package com.wu.leetcode.Leetcode80;

/**
 * Leetcode80-删除排序数组中的重复项 II
 *
 * @author lynn
 * @date 2020/11/6 - 10:12
 */
public class Solution {
    public static int removeDuplicates(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int i = 0;
        for (int j = 0; j < nums.length; j++) {
            if (i < 2 || nums[j] > nums[i - 2]) {
                nums[i++] = nums[j];
            }
        }
        return i;
    }

    public static void main(String[] args) {
        int i = removeDuplicates(new int[]{1, 1, 1, 2, 2, 2, 3});
        System.out.println(i);
    }
}
